import axios from "axios";

// const baseURL = process.env.VUE_APP_BASE_API; // 接口基本路径
// const http = axios.create({
//   timeout: 5000,
//   // withCredentials: true,
//   headers: { 
//     'X-Requested-With': 'XMLHttpRequest', 
//     'accessToken': localStorage.getItem('token'), 
//     'studentId': localStorage.getItem('isDefaultStudent'),
//     'Content-Type': "application/json;charset=UTF-8" 
//   },
//   baseURL
// });

export default{
  //上传
  upload(opts) {
    const axiosUpload = axios.create({
      timeout: 5000,
      headers: {
        'Content-Type': 'multipart/form-data',
        'X-Requested-With': 'XMLHttpRequest',
        'accessToken': "api_0dff946befb74a4788ebebc4e9536faf", 
      }
    });
    // 响应拦截器
    axiosUpload.interceptors.response.use(function(response) {
      // 对错误进行统一处理
      return Promise.resolve(response.data);
    });
    return new Promise((resolve, reject) => {
      axiosUpload
        .post(opts.url, opts.data)
        .then(res => {
          resolve(res);
        })
        .catch(err => {
          reject(err);
        });
    });
  },
}




